add_rules("mode.debug","mode.release")
option("demo")
	set_default(false)
	set_showmenu(true)
option("demo_path")
	set_showmenu(true)

-- includes("src/*.lua")

if has_config("demo") then
	target("main")
		set_targetdir("bin")
        set_kind("binary")
        add_files("$(demo_path)/*.cpp","$(demo_path)/*.c","src/*.cpp")

        add_includedirs("include","$(demo_path)/include","thirdpart/cstructures/include",
            "thirdpart/glad/include","thirdpart/glfw/include","thirdpart/freetype/include","thirdpart/lbmath/include",
            "thirdpart/viewer/include","thirdpart/libcell/include","thirdpart/URDF_Parser/include") 

        add_includedirs("thirdpart/imgui/include","thirdpart","thirdpart/eigen",
            "thirdpart/spectra/include")
        --add_includedirs("thirdpart/libigl/include")
        --add_links("viewer","cstructures")
        add_linkdirs("libs","temp_libs")
 
        --add_deps("viewer")
        -- add_links("avformat","avcodec","avutil","swscale","swresample","m")
        if is_plat("linux") then
            add_syslinks( "viewer","libcell","lbmath","cstructures","cstruct_iterator","glfw3","freetype", "GL", "Xrandr", "Xi", "X11",
                "Xxf86vm", "pthread", "Xinerama", "Xcursor","dl", "png","bz2","z","harfbuzz")
            add_ldflags("-no-pie ")
            add_cflags("-O3")
            add_cxflags("-O3 ")
            add_cxxflags("-O3")
        elseif is_plat("mingw") then
            print("mingw")
            add_syslinks("viewer","libcell","lbmath","cstructures","glfw3","opengl32","freetype","gdi32","comdlg32","advapi32","Z")
            add_ldflags("-no-pie ") 
            add_cxflags("-O2")
            add_cxxflags("-O2")
        else 
            print("not mingw")
            add_cxflags("/MD /O2 ")
            add_cxxflags("/MD /O2 ")
            -- add_syslinks("opengl32","glfw3","freetype","kernel32","user32"
            --     ,"gdi32","comdlg32","advapi32","shell32" )
            add_syslinks("viewer","libcell","lbmath","cstructures","cstruct_iterator", "opengl32","glfw3","freetype","kernel32","user32"
                ,"gdi32","comdlg32","advapi32","shell32" )
        end
end
